package com.itheima.day20.demo06;

import java.io.*;

/***
 * 6. 已知在项目根目录下有一个stu.txt文件，内容如下：
 * 	abc
 * 	def
 * 	ghi
 *
 * 	需求：将此文件拷贝到D盘根目录下的stu.txt文件中，拷贝时在文件每一行的末尾追加当前行数。末尾和行数使用--连接。
 * 	拷贝后的文件内容如下：
 * 		abc--1
 * 		def--2
 * 		ghi--3
 */
public class demo06 {
    public static final String SRC = "./homework/src/com/itheima/day20/demo06/stu6.txt";
    public static final String DEST = "./homework/src/com/itheima/day20/demo06/student6.txt";

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new FileReader(new File(SRC)));
        BufferedWriter bw = new BufferedWriter(new FileWriter(new File(DEST)));
        String s = null;
        int count = 0;
        while ((s = br.readLine()) != null) {
            bw.write(s);
            bw.write(("--" + ++count));
            bw.newLine();
        }

        bw.close();
        br.close();
    }
}
